﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace com.hk.validate.Common
{
    public class RequiredValidator : IValidate
    {
        public RequiredValidator(object value)
        {
            this.Value = value;
        }
        public static bool Validate(object value)
        {
            if (value == null)
            {
                return false;
            }
            //String Type则验证是否为String.Empty
            if (value.GetType().ToString().Equals("System.String"))
            {
                if (string.IsNullOrEmpty(value.ToString()))
                {
                    return false;
                }
            }
            return true;
        }

        public bool Validate()
        {
            return Validate(this.Value);
        }

        public object Value { get; set; }
    }
}
